<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    

<link rel="stylesheet" type="text/css" href="css/edittable.css"  ></link>  
<link rel="stylesheet" type="text/css" href="css/validate.css"  ></link>  
<script type="text/javascript"  src="js/jquery-1.8.0.js"></script>

<script>
		var result = false;
		function validate(){
			if(result){
				var l = confirm("确定要提交吗");
				if(l){
					return true;
				}else{
					return false;
				}
			}else{
				alert("请按要求填写");
				return false;
			}
				
		}
	</script>

<script>
	$(function(){
		//表单校验
		$("#roleName").blur(function(){
			var text = /^.{2,15}$/;
			var a=$("#roleName").val();
			if(text.test(a)){
				$.ajax({
					url:"RoleServlet.do",
					type:"post",
					data:{roleName:a,flag:"check"},
					success:function(data){
						if(data==1){
							$("#roleName_msg").html("√");
							$("#roleName_msg").css("color","green");
							result1=true;
						}else{
							$("#roleName_msg").html("角色名已存在");
							$("#roleName_msg").css("color","red");
							result1=false;
						}
					}
				})
			}else{
				$("#roleName_msg").html("输入错误，2-15位,非空白");
				$("#roleName_msg").css("color","red");
				result1=false;
			}
			
		})
	});		
</script>

</head>

<body>
<div class ="div_title">
		 <div class="div_titlename"> <img src="../images/san_jiao.gif" ><span>角色修改</span></div>
	 </div>
				 
	 <form action="RoleServlet.do?flag=update" method="post">
	 	<input type="hidden" name="id" value="${roleInfo.id}"/>
		 <table class="edit_table" >
		 		<tr>
	 			 	<td class="td_info">角色名称:</td>	
	 			 	<td class="td_input_short">
	 			 		<input type="text" class="txtbox" id="roleName" name="roleName" value="${roleInfo.roleName}"/>
	 			 	</td>   
	 			 	<td>
	 			 		<label class="validate_info" id="roleName_msg">2-15位,非空白</label>
	 			 	</td> 
		 		</tr>
		 		<tr>
		 			<td class="td_info">角色描述:</td>	
		 			<td><textarea rows="4" cols="27" name="des" class="txtarea" >${roleInfo.des}</textarea> </td>	
		 		</tr>
		 		<tr>
		 			<td class="td_info"></td>
		 			<td> 
		 			<input class="form_btn" type="submit" value="提交"  onclick="return validate()"/> 
		 			<input type="reset"  class="form_btn" value="重置" /> </td>	
		 			<td>
		 				<label id="result_msg" class="result_msg">${msg}</label>
		 			</td>	
		 		</tr>
		</table>
     </form>
</body>
</html>